package com.sts.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.sts.bean.Car;
import com.sts.dao.ICar;

@Service
public class CarService implements ICarService {

	
	private Logger log = Logger.getLogger(this.getClass());
	@Resource
	private ICar icar ;
	
	@Override
	public int insertCar(Car car) {
		log.debug("insertCar isUser service in");
		
		int result = icar.insertCar(car) ;
		log.debug("insertCar isUser service out");
		
		return result;
	}

	@Override
	public List<Car> selCar(String car_id, String car_name) {
		log.debug("insertCar isUser service in");
		Map<String,Object> map = new HashMap<String,Object>() ;
		if(car_id == null){
			car_id = "" ;
		}
		if(car_name == null){
			car_name = "" ;
		}
		map.put("car_id", car_id);
		map.put("car_name", car_name) ;
		List<Car> result = new ArrayList<Car>() ;
		result = icar.selectCar(map) ;
		log.debug("insertCar isUser service out");
		
		return result;
	}

	@Override
	public int updateCar(Car car) {
		int result = icar.updateCar(car);
		return result;
	}

	@Override
	public int deleteCar(String car_id) {
		int result = icar.deleteCar(car_id) ;
		return result;
	}

	@Override
	public int selSize(String car_id, String car_name) {
		log.debug("selSize service in");
		Map<String,Object> map = new HashMap<String,Object>() ;
		if(car_id == null){
			car_id = "" ;
		}
		if(car_name == null){
			car_name = "" ;
		}
		map.put("car_id", car_id);
		map.put("car_name", car_name) ;
		int result =  icar.selSize(map) ;
		log.debug("selSize service out");
		
		return result;
	}

}
